<?php

namespace app\appapi\controller;

use app\data\model\LiveFunctionList;

class FunctionList extends BaseController
{
    //获取应用列表
    public function getFunctionList(){
        $userId = $this->checkTokenReturnUserId();
        $functions = LiveFunctionList::mk()
            ->field('function_id,function_name,function_package,function_event_code,function_resid')
            ->where(['function_state' => 1, 'deleted' => 0])
            ->select()->toArray();
        $this->success('查询成功', $functions);
    }
    //提交使用
    public function setFunctionUse(){
        $userId = $this->checkTokenReturnUserId();
        $post = $this->request->post();
        if(!isset($post['function_id'])) $this->error('缺少参数！');
        LiveFunctionList::mk()->where(['function_id' => $post['function_id']])->inc('function_usenum')->update();
        $this->success('提交成功');
    }
}